
function ChaJian() {

}
/**
 *
 * @param jquery的选择器 id
 * @param 回调 func
 */
ChaJian.prototype.getFileUrl=function (id,func) {
    var file = $(id).get(0).files;
    var read = '';
    for(var a=0;a<file.length;a++){
        read = new FileReader();
        read.readAsDataURL(file[a]);
        read.onloadend = function () {
            var src = this.result;
            func(src);
        }
    }
}
/**
 *
 * @param jquery选择器 $id
 * @param 提交地址 $url
 * @param 成功回调 $success
 * @param 失败回调 $error
 * @param 类型默认false $async
 */
ChaJian.prototype.getAjax = function ($id,$url,$success,$error,$async) {
    var type = false;
    if($async){
        type = $async;
    }
    $id.attr('enctype','multipart/form-data');
    var $data=new FormData($id[0]);
    $.ajax({
        url: $url,
        type: 'POST',
        cache: false,
        async:type,
        data: $data,
        processData: false,
        contentType: false,
        success:$success,
        error:$error
    });
}
/**
 *
 * @param 数据 $data
 * @returns 检测是否为空 {string}
 * @constructor
 */
ChaJian.prototype.ToString=function ($data) {
    var str = '';
    if($data&&$data!=='undefined'&&$data!==null){
        str = $data;
    }
    return str;
}
/**
 *
 * @param jquery选择器 $id
 * @returns checkbox的值得数组 {Array}
 * @constructor
 */
ChaJian.prototype.GetCheckBox=function ($id) {
    var array = [];
    $.each($id,function (i,v) {
        if($(v).prop('checked')){
            array.push($(v).val());
        }
    });
    return array;
}
ChaJian.prototype.WeiBo=function ($id,$url,$appkey,$title,$ralateUid,$pic,$language) {
    var web_url = 'http://znch.cybwnt.com';
    if($url){
        web_url = $url;
    }
    var veb_appkey = '4062620418';
    if($appkey){
        veb_appkey = $appkey;
    }
    var web_title = '';
    if($title){
        web_title = $title;
    }
    var web_ralateUid = '';
    if($ralateUid){
        web_ralateUid = $ralateUid;
    }
    var web_pic = '';
    if($pic){
        web_pic = $pic;
    }
    var web_language = 'zh_cn';
    if($language){
        web_language = $language;
    }
    $id.attr('href',"http://service.weibo.com/share/share.php?url="+web_url+"&appkey="+veb_appkey+"&title="+web_title+"&pic="+web_pic+"&ralateUid="+web_ralateUid+"&language="+web_language+"");
}
ChaJian.prototype.ToString=function(data,defaule){
    var str = '';
    if(defaule&&defaule!==undefined&&defaule!==null){
        str = defaule;
    }
    if(data){
        str = data;
    }
    return str;
}
